//
//  XHBannerListViewController.m
//  XHAdSDKTest
//
//  Created by 陈俭红 on 2022/2/16.
//

#import "XHBannerListViewController.h"

//广告头文件
#import <XHAdSDK/XHAdSDK.h>

@interface XHBannerListViewController ()<XHBannerAdDataDelegate>
/* <#name#> */
@property (nonatomic, strong) XHAdCenter *center;

@end

@implementation XHBannerListViewController

//MARK: Cycle Methods
- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.title = @"Banner广告";
    self.view.backgroundColor = [UIColor redColor];
    [self addAllViews];
}

//MARK: Custom Methods
- (void)addAllViews{
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(30, 100, self.view.frame.size.width-60, 20)];
    label1.text = @"";
    label1.textColor = [UIColor blackColor];
    [self.view addSubview:label1];
    UIView *bottomView1 = [[UIView alloc]initWithFrame:CGRectMake(30, 120, self.view.frame.size.width-60, 50)];
    [self.view addSubview:bottomView1];
    
    XHAdCenter * center1 = [XHAdCenter new];
    XHBannerAdData * data1 = [XHBannerAdData new];
    data1.rootViewController = self;
    data1.bannerAdDelegate = self;
    data1.bottomView = bottomView1;
    data1.timeoutInterval = 3;
    data1.isPreload = YES;      //是否预加载 默认NO
    [center1 xh_showBannerAd:data1 appId:@"248199686639321121"];
    self.center = center1;
}

- (void)xh_onBannerActionAdDidLoad {
    NSLog(@"广告预加载成功");
    [self.center xh_showPreloadBannerAd];
}

- (void)xh_onBannerActionAdClicked {
    NSLog(@"广告被点击");
}

- (void)xh_onBannerActionAdDismiss {
    NSLog(@"广告被关闭");
}

- (void)xh_onBannerActionAdExposure {
    NSLog(@"广告渲染成功");
}

- (void)xh_onBannerActionAdFail:(nonnull NSString *)errorString {
    NSLog(@"广告加载失败  %@",errorString);
}

- (void)xh_onBannerAdFullScreenClicked {
    NSLog(@"当点击应用下载或者广告调用系统程序打开");
}

- (void)xh_onBannerAdFullScreenClose {
    NSLog(@"弹出全屏广告页关闭 ");
}

- (void)xh_onBannerAdFullScreenOpen {
    NSLog(@"弹出全屏广告页打开");
}


@end
